//
//  LoginVC.m
//  easyVideo-OC
//
//  Created by 李淼淼 on 2021/7/30.
//

#import "LoginVC.h"

@interface LoginVC ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *serverTF;
@property (weak, nonatomic) IBOutlet UITextField *accoutTF;
@property (weak, nonatomic) IBOutlet UITextField *passwordTF;
@property (weak, nonatomic) IBOutlet UIButton *loginButton;
@property (weak, nonatomic) IBOutlet UIButton *adviceButton;


@end

@implementation LoginVC

- (void)viewDidLoad {
    [super viewDidLoad];
    //绑定按钮方法
    [_loginButton addTarget:self action:@selector(loginButtonAction) forControlEvents:UIControlEventTouchUpInside];
    //设置登录按钮圆角
    _loginButton.layer.cornerRadius = 4.0;
    //设置按钮文字
    [_adviceButton setTitle:@"高级设置" forState:UIControlStateNormal];
    //绑定代理
    _serverTF.delegate = self;
    _accoutTF.delegate = self;
    _passwordTF.delegate = self;
    
}
- (IBAction)backAction:(id)sender {
    //返回上一个界面
    [self.navigationController popViewControllerAnimated:true];
}
//添加按钮方法
- (void)loginButtonAction{
    NSLog(@"点击了登录");
    if (_serverTF.text.length == 0) {
        return;
    }else if (_accoutTF.text.length == 0){
        
    }else if (_passwordTF.text.length == 0){
        
    }
    NSLog(@"server text:%@, accout text:%@, password text:%@", _serverTF.text, _accoutTF.text, _passwordTF.text);
}
//实现textfield的代理
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    //区分是哪一个输入框的代理
    if (textField == _serverTF) {
        //server 不允许超过5个数,从0开始计算
        NSLog(@"server text:%@", _serverTF.text);
        if (_serverTF.text.length > 4) {
            return NO;
        }
    }else if (textField == _accoutTF){
        //accout 不允许超过10个数
        NSLog(@"accout text:%@", _accoutTF.text);
        if (_accoutTF.text.length > 9) {
            return NO;
        }
        
    }else if (textField == _passwordTF){
        //password 不允许超过10位数
        NSLog(@"password text:%@", _passwordTF.text);
        if (_passwordTF.text.length > 10) {
            return NO;
        }
    }else{
        
    }
    return true;
}
    
    
    
    
    


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
